package com.itboye.hutouben.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.itboye.hutouben.R;
import com.itboye.hutouben.base.MyApplcation;
import com.itboye.hutouben.bean.BankCodeBean;

import java.util.List;

/**
 * 我的账户
 */

public class ZhangHuAdapter extends BaseAdapter {
    List<BankCodeBean> bean;
    Context context;

    public ZhangHuAdapter(List<BankCodeBean> bean,
                        Context context) {
        this.context = context;
        this.bean = bean;

    }

    @Override
    public int getCount() {
        return bean.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHoudr houdr;
        if (convertView == null) {
            houdr = new ViewHoudr();
            convertView = LayoutInflater.from(MyApplcation.ctx).inflate(R.layout.item_zhnghu, null);
            houdr.MessgeName = (TextView) convertView.findViewById(R.id.tvMessgeName);
            houdr.MessgeTitle = (TextView) convertView.findViewById(R.id.tvMessgeTitle);
            houdr.tvMessgeTime = (TextView) convertView.findViewById(R.id.tvMessgeTime);
    //        houdr.imgzhifubao = (ImageView) convertView.findViewById(R.id.imgzhifubao);
            houdr.linitem = (LinearLayout) convertView.findViewById(R.id.linitem);

            convertView.setTag(houdr);
        } else {
            houdr = (ViewHoudr) convertView.getTag();
        }
        houdr.imgzhifubao.setVisibility(View.GONE);
        houdr.MessgeName.setText(bean.get(position).getName());
        if (bean.get(position).getAccount_type().equals("6179")) {
            houdr.imgzhifubao.setBackgroundResource(R.drawable.zhifubao);
            houdr.linitem.setBackgroundResource(R.drawable.alipay);
        } else {
//                houdr.imgzhifubao.setBackgroundResource(R.drawable.);
            houdr.imgzhifubao.setBackgroundResource(R.drawable.yinhangkazhifu);
            houdr.linitem.setBackgroundResource(R.drawable.bank);
        }

        houdr.MessgeTitle.setText(bean.get(position).getName());
        houdr.tvMessgeTime.setText(bean.get(position).getAccount());

        return convertView;
    }

    private class ViewHoudr {
        private TextView MessgeTitle;
        private TextView MessgeName;
        ImageView imgzhifubao;
        private TextView tvMessgeTime;
        LinearLayout linitem;
    }
}
